// 定义全局变量u
var ue = {};
//定义全局变量函数
var ueStorage = function () {
    var ls = window.localStorage;
    return ls;
};
// 设置缓存
ue.setStorage = function (key, value) {
    var v = value;
    if (typeof v == 'object') {
        v = JSON.stringify(v);
        v = 'obj-' + v;
    } else {s
        v = 'str-' + v;
    }
    var ls = ueStorage();
    if (ls) {
        ls.setItem(key, v);
    }
};
// 获取缓存
ue.getStorage = function (key) {
    var ls = ueStorage();
    if (ls) {
        var v = ls.getItem(key);
        if (!v) {
            return "";
        }
        if (v.indexOf('obj-') === 0) {
            v = v.slice(4);
            return JSON.parse(v);
        } else if (v.indexOf('str-') === 0) {
            return v.slice(4);
        }
    }
};
// 清楚缓存
ue.clearStorage = function () {
    var userId = ue.getStorage("userId")
    var shopId = ue.getStorage("shopId")
    var currentLat = ue.getStorage("currentLat")
    var currentLng = ue.getStorage("currentLng")
    var returnRatio = ue.getStorage("returnRatio")
    var ls = ueStorage();
    ls.clear()
    if (userId){
        ue.setStorage("userId",userId)
    }
    if (currentLat){
        ue.setStorage("currentLat",currentLat)
    }
    if (currentLng){
        ue.setStorage("currentLng",currentLng)
    }
    if (returnRatio){
        ue.setStorage("returnRatio",returnRatio)
    }
    if (shopId){
        ue.setStorage("shopId",shopId)
    }
};




